package com.nantong.common.core.enums.commonEnums;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 产品类型枚举
 *
 * @author nantong
 */
@Getter
@AllArgsConstructor
public enum ProductTypeEnum {
    MEDICAL_DEVICE(1, "医疗器械"),
    PESTICIDE(2, "农药"),
    CHEMICAL(3, "化学品"),
    COSMETIC(4, "化妆品"),
    OTHER(5, "其他");

    @JsonValue
    private final Integer code;
    private final String desc;

    public static ProductTypeEnum fromCode(Integer code) {
        for (ProductTypeEnum value : ProductTypeEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
}